using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace MagicAttributeTest
{
  public partial class UCAbility : UserControl
  {
    Permanent m_Permanent;

    public event GUIAbilityEventHandler evClickAbility;

    public UCAbility()
    {
      InitializeComponent();
    }

    public void SetPermanent(Permanent permanent)
    {
      m_Permanent = permanent;
    }

    public void UpdateGUI()
    {
      if (m_Permanent == null) 
        return;
      List<Ability> abilities = m_Permanent.GetAbilites();
      lbAbilities.Items.Clear();
      foreach (Ability a in abilities)
      {
        lbAbilities.Items.Add(a);
      }
    }

    private void lbAbilities_MouseDoubleClick(object sender, MouseEventArgs e)
    {
      if (e.Button == MouseButtons.Left)
      {
        if (lbAbilities.SelectedItem != null)
        {
          Ability ability = (Ability)lbAbilities.SelectedItem;
          if (evClickAbility != null)
            evClickAbility(m_Permanent, ability);
        }
      }
    }
  }
}
